/**
 * The contents of this file are subject to the license and copyright detailed in the LICENSE and NOTICE files at the root of the source tree and available online at
 * http://www.askosi.org/license.html
 */
package be.destin.skos.search;



import org.apache.log4j.Logger;

import be.destin.skos.core.SchemeInterface;

/**
 * @author Christophe Dupriez
 *
 */
public class SearchType
{
    private static final Logger log = Logger.getLogger(SearchType.class);

    private int input = -2; // not specified at all
    private String index = null;
    private String list = null;
    private String label = null;
    private String icon = null;

    public String getAbout() {
        return ( input>=0 ? ""+input : "" )
               + SchemeInterface.separator +
               ( index != null ? index : "")
               + ( list != null ? SchemeInterface.separator+list : "");
    }

    public void setAbout(String anAbout) {
        if (anAbout==null) return;
        int pos1 = anAbout.indexOf(SchemeInterface.separator);
        if (pos1 < 0) this.setIndex(anAbout);
        else {
            if (pos1 > 0) this.setInput(Integer.parseInt(anAbout.substring(0,pos1)));
            else this.setInput(-1); // specified but NO autocomplete
            int pos2 = anAbout.indexOf(SchemeInterface.separator,pos1+1);
            if (pos2 < 0) this.setIndex(anAbout.substring(pos1+1));
            else {
                this.setIndex(anAbout.substring(pos1+1,pos2));
                this.setList(anAbout.substring(pos2+1));
            }
        }
    }

    /**
     * @return the input
     */
    public int getInput()
    {
        return input;
    }

    /**
     * @param input the input to set
     */
    public void setInput(int input)
    {
        this.input = input;
    }

    /**
     * @return the index
     */
    public String getIndex()
    {
        return index;
    }

    /**
     * @param index the index to set
     */
    public void setIndex(String index)
    {
        this.index = index;
    }

    /**
     * @return the list
     */
    public String getList()
    {
        return list;
    }

    /**
     * @param list the list to set
     */
    public void setList(String list)
    {
        this.list = list;
    }

    /**
     * @return the label
     */
    public String getLabel()
    {
        return label;
    }

    /**
     * @param label the label to set
     */
    public void setLabel(String label)
    {
        this.label = label;
    }
    
    /**
     * @return the icon
     */
    public String getIcon()
    {
        return icon;
    }

    /**
     * @param icon the icon to set
     */
    public void setIcon(String icon)
    {
        this.icon = icon;
    }
}
